<#include "../common/layout/__mainlayout.html">

    <!--设置面包屑-->
    <#assign pageBreadCrumbs>
        <li class="active"><a href="#">系统管理</a></li>
        <li class="active">系统参数</li>
    </#assign>
    <#assign pageCss>
        <!-- page specific plugin styles -->
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
    </#assign>

    <#assign pageJavascript>
        <script src="${ctx}/static/admin/assets/js/jquery.validate.js"></script>
        <script src="${ctx}/static/admin/assets/js/jquery.validate.messages_zh.js"></script>
        <script type="text/javascript">
            jQuery(function ($) {
                <!--获取系统参数-->
                $.get("${ctx}/system/getConfig.do",
                    function (data) {
                        $("#webName").val(data.data.webName);
                        $("#webCopyright").val(data.data.webCopyright);
                        $("#webUrl").val(data.data.webUrl);
                        $("#keywords").val(data.data.keywords);
                        $("#description").val(data.data.description);
                    });


                $("#sysForm").validate({
                    errorElement: 'div',
                    errorClass: 'help-block',
                    focusInvalid: true,
                    highlight: function (e) {
                        $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
                    },
                    success: function (e) {
                        $(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
                        $(e).remove();
                    },
                    errorPlacement: function (error, element) {
                        if(element.is('input[type=checkbox]') || element.is('input[type=radio]')) {
                            var controls = element.closest('div[class*="col-"]');
                            if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
                            else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
                        }
                        else if(element.is('.select2')) {
                            error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
                        }
                        else if(element.is('.chosen-select')) {
                            error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
                        }
                        else error.insertAfter(element.parent());
                    },

                    submitHandler: function (form) {
                        $.ajax({
                            cache: true,
                            type: "POST",
                            url:"${ctx}/system/saveConfig.do",
                            data:$('#sysForm').serialize(),// 你的formid
                            async: true,
                            error: function(request) {
                                alert("Connection error");
                            },
                            success: function(data) {
                                if(data.result == "success"){
                                    window.location="${ctx}/system/sysconfig.html";
                                }else{
                                    alert(msg.messages);
                                }
                            }
                        });
                    },
                    invalidHandler: function (form) {
                    }
                })


            })
        </script>
    </#assign>

    <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript currentMenu="systemFlag-systemParamFlag">

    <form id="sysForm" class="form-horizontal" action="${ctx}/system/saveConfig.do" method="post">
        <!---版本信息----->
        <div class="row">
            <div class="col-sm-12">
                <div class="widget-box">
                    <div class="widget-header ">
                        <h4 class="widget-title">系统信息</h4>
                    </div>
                    <div class="widget-body">
                        <div class="widget-main">
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right"
                                       for="webName">站点名称:</label>

                                <div class="col-xs-12 col-sm-5">
                                    <div class="clearfix">
                                        <input type="text"  name="webName" id="webName"
                                               class="form-control col-sm-4 required" value=""/>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right" for="webCopyright">版权信息:</label>

                                <div class="col-xs-12 col-sm-5">
                                    <div class="clearfix">
                                        <input type="text"  name="webCopyright" id="webCopyright"
                                               class="form-control col-sm-4 required" value=""/>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right"
                                       for="webUrl">url地址:</label>

                                <div class="col-xs-12 col-sm-5">
                                    <div class="clearfix">
                                        <input type="text"  name="webUrl" id="webUrl"
                                               class="form-control col-sm-4 required" value=""/>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right"
                                       for="keywords">关键词:</label>

                                <div class="col-xs-12 col-sm-5">
                                    <div class="clearfix">
                                        <input type="text" name="keywords" id="keywords"
                                               class="form-control col-sm-4 required" value=""/>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right"
                                       for="description">描述:</label>

                                <div class="col-xs-12 col-sm-5">
                                    <div class="clearfix">
                                        <input type="text" name="description" id="description"
                                               class="form-control col-sm-4 required" value=""/>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="clearfix form-actions">
            <div class="col-md-offset-3 col-md-9">
                <button class="btn btn-info"  type="submit" id="saveButton">
                    <i class="ace-icon fa fa-check bigger-110"></i> 保存
                </button>
            </div>
        </div>
    </@mainlayout>

    </form>